package com.petshop.inventoryentries.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.petshop.common.annotation.Log;
import com.petshop.common.core.controller.BaseController;
import com.petshop.common.core.domain.AjaxResult;
import com.petshop.common.enums.BusinessType;
import com.petshop.inventoryentries.domain.PetInventoryentries;
import com.petshop.inventoryentries.service.IPetInventoryentriesService;
import com.petshop.common.utils.poi.ExcelUtil;
import com.petshop.common.core.page.TableDataInfo;

/**
 * 商品入库信息Controller
 * 
 * @author ruoyi
 * @date 2024-09-11
 */
@RestController
@RequestMapping("/inventoryentries/inventoryentries")
public class PetInventoryentriesController extends BaseController
{
    @Autowired
    private IPetInventoryentriesService petInventoryentriesService;

    /**
     * 查询商品入库信息列表
     */
    @PreAuthorize("@ss.hasPermi('inventoryentries:inventoryentries:list')")
    @GetMapping("/list")
    public TableDataInfo list(PetInventoryentries petInventoryentries)
    {
        startPage();
        List<PetInventoryentries> list = petInventoryentriesService.selectPetInventoryentriesList(petInventoryentries);
        return getDataTable(list);
    }

    /**
     * 导出商品入库信息列表
     */
    @PreAuthorize("@ss.hasPermi('inventoryentries:inventoryentries:export')")
    @Log(title = "商品入库信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PetInventoryentries petInventoryentries)
    {
        List<PetInventoryentries> list = petInventoryentriesService.selectPetInventoryentriesList(petInventoryentries);
        ExcelUtil<PetInventoryentries> util = new ExcelUtil<PetInventoryentries>(PetInventoryentries.class);
        util.exportExcel(response, list, "商品入库信息数据");
    }

    /**
     * 获取商品入库信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('inventoryentries:inventoryentries:query')")
    @GetMapping(value = "/{inventoryEntryID}")
    public AjaxResult getInfo(@PathVariable("inventoryEntryID") Long inventoryEntryID)
    {
        return success(petInventoryentriesService.selectPetInventoryentriesByInventoryEntryID(inventoryEntryID));
    }

    /**
     * 新增商品入库信息
     */
    @PreAuthorize("@ss.hasPermi('inventoryentries:inventoryentries:add')")
    @Log(title = "商品入库信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PetInventoryentries petInventoryentries)
    {
        return toAjax(petInventoryentriesService.insertPetInventoryentries(petInventoryentries));
    }

    /**
     * 修改商品入库信息
     */
    @PreAuthorize("@ss.hasPermi('inventoryentries:inventoryentries:edit')")
    @Log(title = "商品入库信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PetInventoryentries petInventoryentries)
    {
        return toAjax(petInventoryentriesService.updatePetInventoryentries(petInventoryentries));
    }

    /**
     * 删除商品入库信息
     */
    @PreAuthorize("@ss.hasPermi('inventoryentries:inventoryentries:remove')")
    @Log(title = "商品入库信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{inventoryEntryIDs}")
    public AjaxResult remove(@PathVariable Long[] inventoryEntryIDs)
    {
        return toAjax(petInventoryentriesService.deletePetInventoryentriesByInventoryEntryIDs(inventoryEntryIDs));
    }
}
